package com.bw.service;

import com.bw.common.ZzyUtils;
import com.bw.domain.Message;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class SmsService {
    @Autowired
    RedisTemplate redisTemplate;
    @Retryable
    public  void smsend(Message message){
        Boolean b = redisTemplate.opsForValue().setIfAbsent(message.getOderNO().toString(), 1);
        if (!b){
            return;
        }

        ZzyUtils.sendSms(message.getPhone(),message.getMsg(),5);
    }
}
